<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wx_login_session', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('微信用户登录session信息');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->string('appid', 32)->comment('appid')->default('');
            $table->string('openid', 32)->comment('用户openid')->default('');
            $table->string('unionid', 64)->comment('用户unionid')->default('');
            $table->string('session_key', 64)->comment('session_key')->default('');
            $table->integer('login_time')->comment('最后登录时间')->unsigned()->default(0);
            $table->string('token', 32)->comment('票据')->default('');

            $table->index('create_time');
            $table->index('appid');
            $table->index('openid');
            $table->index('unionid');
            $table->index('login_time');
            $table->index('token');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_login_session');
    }
};
